Checking if %Y exists in current file in VimScript [closed]

Posted by Eduan on Programmers See other posts from Programmers or by Eduan
Published on 2012-11-09T19:44:30Z Indexed on 2012/11/09 23:22 UTC
Read the original article Hit count: 267

Filed under:

Like the title says.

I would love to know how, with VimScript, I can do an if statement, that checks if %Y (for statusline) exists in the current file. This is what I have so far:

if expand('%:Y') != ""
    let filetype=extend('%:Y')
    let filetype+= ",\ "
else
    let filetype=""
endif

This is, of course, for my statusline, for which I don't want to show the filetype comma and space if the filetype doesn't exist.

BTW, this is a direct copy of this StackOverflow question: http://stackoverflow.com/questions/13314264/checking-if-y-exists-in-current-file-in-vimscript

© Programmers or respective owner

Related posts about vim